<template>
  <div class="foodlistItem">
    <div class="left">
      <img src="@/assets/images/food.jpg" alt="" />
    </div>
    <div class="text">
      <div class="name">{{ FoodItem.title }}</div>
      <div class="icon">
        <!-- 加号图标 -->
        <van-icon
          name="add-o"
          v-if="FoodItem.add"
          @click="handleAdd(FoodItem.id)"
        />
        <!-- 步进器 -->
        <van-stepper
          v-else
          v-model="FoodItem.num"
          @change="handleChange"
          :name="FoodItem.id"
        />
      </div>
    </div>
    <div class="right">
      <div class="price">￥{{ FoodItem.price }}</div>
    </div>
  </div>
</template>

<script setup>
defineProps(["FoodItem", "handleAdd", "handleChange"]);
</script>

<style lang="less" scoped>
.foodlistItem {
  display: flex;
  padding: 10px;
  justify-content: space-between;
  .left {
    margin-right: 10px;
    display: flex;
    align-items: center;
    img {
      width: 80px;
      height: 80px;
      border-radius: 5px;
    }
  }

  .text {
    width: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .name {
      font-size: 14px;
      font-weight: 600;
    }
    .icon {
      display: flex;
      align-items: center;
    }
  }
  .right {
    display: flex;
    flex: 1;
    .price {
      font-weight: bold;
    }
  }
}
/deep/.van-icon {
  color: red;
  font-size: 16px;
  margin-left: 60px;
}
</style>
